package com.example.controller;


import com.example.common.annotation.RepeatSubmit;
import com.example.common.utils.R;
import com.example.system.service.IRoleMenuService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 王鹤蒲
 * @since 2023-08-13
 */
@RestController
@Api(tags = "角色菜单信息API",description="提供角色菜单信息相关的 REST API")
@RequestMapping("/role-menu")
public class RoleMenuController {

    @Autowired
    private IRoleMenuService iRoleMenuService;

    @RequestMapping(value = "/save/{roleId}",method = RequestMethod.POST)
    @RepeatSubmit(lockTime = 5)
    @ResponseBody
    public R insertRoleMenu(@PathVariable Integer roleId, @RequestBody List<Integer> menuIds) {
        System.out.println(menuIds);
        iRoleMenuService.insertBatch(roleId,menuIds);
       return R.success();
    }

    @RequestMapping(value = "/save/{roleId}",method = RequestMethod.GET)
    @ResponseBody
    public R selectRoleMenuByRoleId(@PathVariable Integer roleId) {
       return iRoleMenuService.selectMenuIdByRoleId(roleId);
    }
}

